/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package planspiel;

import javax.swing.JLabel;

/**
 * 
 * @author Administrator
 */
public class BudgetTimer extends AbstractTimer {
	
	private int intervallCount = 15;
	private int finishedCount = 25;
	private GameRound round;
	
        /**
         * 
         * @param round
         */
        public BudgetTimer(GameRound round) {
		this.round = round;
	}
	
        /**
         * 
         */
        @Override
	public void fireChangedEvent() {
		intervallCount--;
		if (intervallCount == 0) {
			intervallCount = 15;
			finishedCount--;
			if (finishedCount >= 0) {
				int amount = (int)(round.getVacancy().getVacancyBudget() * 0.02);
				round.reduceScore(amount);
	            for (JLabel each: changedListener) {
                    each.setText(round.getScoreAsString());
	            }
			}
		}
        if (getRestzeit() <= 0) {
        	getTimer().cancel();
            fireFinishedEvent();
        }
	}

        /**
         * 
         */
        @Override
	public void fireFinishedEvent() {
	}

}
